package com.tico.editor.editors.kafkaThread;

import com.tico.editor.editors.domain.Kafka;
import com.tico.editor.editors.service.HttpEditorService;
import com.tico.editor.editors.service.KafkaService;
import com.tico.editor.editors.service.KafkaTopicService;
import org.apache.kafka.clients.consumer.KafkaConsumer;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Properties;
import java.util.concurrent.ConcurrentLinkedQueue;

public class KafkaChangeToipcThread implements Runnable{
    private KafkaService kafkaService;
    private KafkaTopicService kafkaTopicService;
    private HttpEditorService httpEditorService;

    public KafkaChangeToipcThread(KafkaService kafkaService, KafkaTopicService kafkaTopicService, HttpEditorService httpEditorService) {
        this.kafkaService = kafkaService;
        this.kafkaTopicService = kafkaTopicService;
        this.httpEditorService = httpEditorService;
    }

    public KafkaChangeToipcThread(KafkaService kafkaService, KafkaTopicService kafkaTopicService) {
        this.kafkaService = kafkaService;
        this.kafkaTopicService = kafkaTopicService;
    }
    @Override
    public void run() {
        while (true){
            try {
                Thread.sleep(20000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            HashMap<String,Object> param = new HashMap<>();
            param.put("status","true");
            List<String> topicByParamList = kafkaTopicService.findTopicByParamList(param);
            KafkaThread.subscribedTopics.addAll(topicByParamList);
        }
    }
}
